<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<div id="app">
    <ul>
        <li v-for="(p,index) in persons" :key="index">
            {{index}}-----{{p.name}}-----{{p.age}}
            ----- <button @click="delP(index)">删除</button>
            ----- <button @click="updateP(index,{name:'kkkk',age:1})">更新</button>
        </li>
    </ul>
</div>

<script src="../js/vue.js"></script>
<script>
    new Vue({
        el: '#app',
        data: {
            persons: [
                {name: 'kongwg', age: 18},
                {name: 'zhnagsang', age: 19},
                {name: 'lise', age: 19}
            ]
        },
        methods:{
            delP(index){
                this.persons.splice(index,1)
            },
            updateP(index,newP){
                this.persons.splice(index,1,newP)
            }
        }
    })
</script>
<body>

</body>
</html>